package org.linlinjava.litemall.wxserver.web;

import org.linlinjava.litemall.core.util.ResponseUtil;
import org.linlinjava.litemall.db.domain.LitemallMechanismVo;
import org.linlinjava.litemall.db.service.LitemallMechanismService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/wxs/search")
public class WxSearchController {
    @Autowired
    private LitemallMechanismService mechanismService;

    /**
     * 查询机构
     * @param longitude
     * @param latitude
     * @param name
     * @param page
     * @param size
     * @return
     */
    @GetMapping("/searchMechanism")
    public Object searchMechanism(String longitude, String latitude, String name,
        @RequestParam(value = "page", defaultValue = "1") Integer page,
        @RequestParam(value = "size", defaultValue = "10") Integer size) {
//         longitude = "118.768250";
//         latitude = "31.986480";
        List<LitemallMechanismVo> list = mechanismService.searchAllMechanism(longitude, latitude, name,page,size);
        Map<String, Object> data = new HashMap(16);
        data.put("list", list);
        return ResponseUtil.ok(data);
    }
}
